package com.lkd.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.lkd.entity.Order;
import com.lkd.entity.Role;
import com.lkd.mapper.RoleMapper;
import com.lkd.service.OrderService;
import com.lkd.service.RoleService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: Z.lx
 * @Date: 2025/8/22 18:50
 * @Description:
 **/
@RequestMapping("/api")
@RestController
@AllArgsConstructor
public class RoleController {
    private final RoleService roleService;
    private final OrderService orderService;
    /**
    * @Description 获取所有角色
    * @Param []
    * @Date 2025/8/22 18:53
    **/
    @GetMapping("/user-service/role")
    public List<Role> list(){
        return roleService.list();
    }

    @GetMapping("/status-service/status/top10")
    public List<Order> top10(){
        LambdaQueryWrapper<Order> qw = new LambdaQueryWrapper<>();
        qw.eq(Order::getStatus,2);
        qw.orderByDesc(Order::getAmount);
        qw.last("limit 10");
        return orderService.list(qw);
    }
}
